﻿using Newtonsoft.Json;

namespace NetMicro.Core.ApiFunction
{
    /// <summary>
    /// 服务接口统一响应
    /// </summary>
    public interface IServiceResult
    {
        /// <summary>
        /// 请求id
        /// </summary>
        [JsonProperty("requestId", NullValueHandling = NullValueHandling.Ignore)]
        string RequestId { get; set; }
        /// <summary>
        /// 是否成功
        /// </summary>
        [JsonIgnore]
        bool Successful { get; }
        /// <summary>
        /// 状态码
        /// </summary>
        [JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)]
        int Code { get; set; }


        /// <summary>
        /// 消息
        /// </summary>
        [JsonProperty("msg", NullValueHandling = NullValueHandling.Ignore)]
        string Msg { get; set; }

        /// <summary>
        /// 服务器时间戳
        /// </summary>
        [JsonProperty("timestamp", NullValueHandling = NullValueHandling.Ignore)]
        long Timestamp { get; }

        /// <summary>
        /// 服务来源
        /// </summary>
        [JsonProperty("source", NullValueHandling = NullValueHandling.Ignore)]
        string Source { get; }
    }
    /// <summary>
    /// 服务接口统一响应
    /// </summary>
    public interface IServiceResult<TData> : IServiceResult
    {
        /// <summary>
        /// 返回值
        /// </summary>
        [JsonProperty("data", NullValueHandling = NullValueHandling.Ignore)]
        TData Data { get; set; }
    }
}
